﻿$(function () {
   
    ajaxCall('../DataService.asmx/GetSessionsForCurrent', false, "",
                function (msg) {
                    if (msg.d == null) {
                        $('#sessions').html("Sessions to be added soon...");
                    } else {
                        for (var i in msg.d) {
                            var speakers = msg.d[i].Speakers[0].FirstName + " " + msg.d[i].Speakers[0].LastName;
                            for (var j = 1; j < msg.d[i].Speakers.length; j++) {
                                speakers = speakers + " & " + msg.d[i].Speakers[j].FirstName + " " + msg.d[i].Speakers[j].LastName;
                            }
                            var sessions = [
                                { ID: msg.d[i].ID, Title: msg.d[i].Title, Description: msg.d[i].Description, Language: msg.d[i].Language, Speakers: speakers }
                            ];
                            $('#SessionTemplate').tmpl(sessions).appendTo('#sessions');
                        }
                    }
                },
                function () {
                    alert("Error hapend while reading from database");
                }
            );

     ajaxCall('../DataService.asmx/GetCurrentEvent', false, "",
        function (msg) {
            if (msg.d.Finished == '0') {
                $('.lkToFinished').css('display', 'none');
            }
        },
        function () {
            alert("Error happend while reading data from database");
        }
    );
});
